{extend name='public/layer_base' /}
{block name='content'}
<div class="layui-fluid content">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-row">
                <form class="layui-form" method="post">
                    <!-- 表单字段区域 -->

                    <div class="layui-form-item">
                        <label for="avatar" class="layui-form-label">头像</label>
                        <div class="layui-input-inline">
                            <div class="layui-upload-drag" id="avatar">
                                <i class="layui-icon"></i>
                                <p>点击上传，或将文件拖拽到此处</p>
                            </div>
                            <div class="layui_img">
                                <div class="layui-progress thumb_progress" id="avatar_progress" lay-showPercent="yes"
                                    lay-filter="progressBaravatar">
                                    <div class="layui-progress-bar layui-bg-red" lay-percent="0%"></div>
                                </div>
                                <img src="{$data.avatar|default=''}" {if !isset($data.avatar) || $data.avatar=='' }
                                    style="display: none;" {/if} id="srcimgavatar" alt="" class="srcimgavatar"
                                    srcset="">
                                <input type="hidden" name="avatar" id="inputimgavatar"
                                    value="{$data.avatar|default=''}">
                            </div>
                        </div>
                    </div>
                    <script>
                        layui.use('upload', function () {
                            var upload = layui.upload;
                            upload.render({
                                elem: '#avatar'
                                , url: "{:url('upfile/upload')}"
                                , acceptMime: 'image/*'
                                , accept: 'images'
                                , size: 1024
                                , progress: function (n, elem, res, index) {
                                    $('#avatar_progress').show();
                                    var percent = n + '%'
                                    element.progress('progressBaravatar', percent);
                                }
                                , done: function (res, index, upload) {
                                    if (res.code == 1) {
                                        $("#inputimgavatar").val(res.data.url);
                                        $('#avatar_progress').hide();
                                        $("#srcimgavatar").attr('src', res.data.url).show();
                                    } else {
                                        layer.msg(res.msg, { icon: 2, time: 2000 });
                                        element.progress('progressBaravatar', '0%');
                                        $('#avatar_progress').hide();
                                    }

                                }
                            });
                        })
                    </script>

                    <div class="layui-form-item">
                        <label for="username" class="layui-form-label">用户名</label>
                        <div class="layui-input-inline">
                            <input id="username" name="username" value="{$data.username|default=''}"
                                placeholder="请输入用户名" type="text" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="nickname" class="layui-form-label">昵称</label>
                        <div class="layui-input-inline">
                            <input id="nickname" name="nickname" value="{$data.nickname|default=''}" placeholder="请输入昵称"
                                type="text" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="mobile" class="layui-form-label">手机号</label>
                        <div class="layui-input-inline">
                            <input id="mobile" name="mobile" value="{$data.mobile|default=''}" placeholder="请输入手机号"
                                type="tel" lay-verify="phone" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="user_level_id" class="layui-form-label">用户等级</label>
                        <div class="layui-input-inline">
                            <select name="user_level_id" id="user_level_id" lay-search>
                                <option value="">请选择用户等级</option>
                                <option value=""></option>
                                {foreach user_level_list as $key=>$value}
                                <option value="{$key}" {if isset($data) && $data.user_level_id==$value.id}selected{/if}>
                                    {$value.name}</option>
                                {/foreach}



                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="password" class="layui-form-label">密码</label>
                        <div class="layui-input-inline">
                            <input id="password" name="password"
                                value="{$data.password|default='JDJ5JDEwJGRuQnBrbE10RG9oU1EyY0ZpejZVRS45YWh2dmsxNjJ6aWU1amlnWkpkTTRPZkxmeVpJNjlL'}"
                                placeholder="请输入密码" type="password" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="status" class="layui-form-label">是否启用</label>
                        <div class="layui-input-inline">
                            <input type="checkbox" name="status" lay-skin="switch" lay-text="是|否" id="status" value="1"
                                {if(!isset($data) ||$data.status==1)}checked{/if}>
                        </div>
                    </div>


                    <!-- 表单底部 -->
                    <div class="layui-form-item">
                        <label for="L_repass" class="layui-form-label"></label>
                        <button class="layui-btn" lay-filter="submit" id="submit" lay-submit="submit"
                            type="button">保存</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

{/block}